#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int arr[4] = { 2,0,1,9 };
	int i = 0; int n = 0; int sumall = 0; int sumfour = 0;
	scanf("%d", &n); int j = 0;
	for (i = 0; i < n; i++)
	{
		if (i < 4)
		{
			printf("%d ", arr[i]); sumall += arr[i];
		}
		else
		{
			for (j = 0; j < 4; j++)
			{
				sumfour += arr[j];
			}
			for (j = 0; j < 4; j++)
			{
				if (j < 3)
				{
					arr[j] = arr[j + 1];
				}
				else
				{
					arr[j] = sumfour % 10; sumall += arr[j];
					printf("%d ", arr[j]);
				}
			}
			sumfour = 0;
		}
	}
	printf("\n%d", sumall);

}